﻿/***********************************************************************
 *            Project: boda.utilities                                  
 *                Web:                            
 *        ProjectName: 通用类                                
 *             Author: 杨云军                                          
 *              Email: yyj_17@163.com                                
 *           Versions: 1.0                                             
 *         CreateTime: 2020-02-01 17:48:52
 *          NameSpace: boda.utilities.Extensions
 *           FileName: boda.utilities
 *   ClassDescription:
 ***********************************************************************/
namespace boda.utilities.Extensions
{
    public static class StringExtensions
    {
        /// <summary>
        /// 判断字符串是否不为空
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool NotNullOrEmpty(this string s)
        {
            return !string.IsNullOrEmpty(s);
        }

        /// <summary>
        /// 判断是否为空
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static bool IsNullOrEmptyString(this string s)
        {
            return string.IsNullOrEmpty(s);
        }

        public static string? TrimEmpty(this string s)
        {
            if (s.NotNullOrEmpty())
            {
                return s?.Trim()?.Replace("\0", "").Replace(" ", "").Replace("\r", "").Replace("\n", "");
            }
            return null;
        }
    }
}
